Use errors.Is() in templates#3736
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors error checks to use errors.Is() for better reliability when comparing wrapped errors.
- Replaced direct
err ==comparisons witherrors.Is(err, ...)across payload decode functions, templates, client SSE code, and example clients. - Updated template files and golden examples to reflect these changes.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| http/codegen/testdata/payload_decode_functions.go | Swapped err == ... with errors.Is(err, ...) |
| http/codegen/templates/request_decoder.go.tpl | Updated EOF checks to use errors.Is |
| http/codegen/templates/partial/request_elements.go.tpl | Updated cookie error check to use errors.Is |
| http/codegen/templates/client_sse.go.tpl | Swapped SSE error checks to use errors.Is |
| codegen/example/testdata/*.golden | Updated flag error checks to use errors.Is |
| codegen/example/templates/client_endpoint_init.go.tpl | Updated flag error check to use errors.Is |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Member
|
Thank you! |
3 tasks
raphael
pushed a commit
that referenced
this pull request
May 18, 2026
…3927) #3736 changed `err == flag.ErrHelp` to `errors.Is(err, flag.ErrHelp)` in `codegen/example/templates/client_endpoint_init.go.tpl` so the generated example client passes `golangci-lint` with `errorlint` enabled. That fix was later overwritten by #3734 (Add JSON-RPC 2.0 Transport Support, commit 8931cbb), which appears to have rebased on a pre-#3736 state and silently reverted the line back to `err == flag.ErrHelp`. This commit restores the `errors.Is` form and updates the affected golden testdata files. No other source change is required — the `errors` package is already in the import spec list for the generated file (`codegen/example/example_client.go:41`).
This was referenced May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #3541